<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragments :: head(~{::title})">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>博客管理登录</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
  <link rel="stylesheet" href="../../static/css/me.css">
</head>
<body>

<br>
<br>
<br>
 <div class="m-container-small m-padded-tb-massive" style="max-width: 25em !important;">
   <div class="ur container">
     <div class="ui middle aligned center aligned grid">
       <div class="column">
         <h2 class="ui teal image header">
           <div class="content">
             博客后台登录
           </div>
         </h2>
         <form class="ui large form" method="post" action="#" th:action="@{/admin/login}">
           <div class="ui  segment" style="background-color: black">
             <div class="field">
               <div class="ui left icon input">
                 <i class="user icon"></i>
                   <input type="text" name="username" placeholder="请输入管理员用户名"/>
               </div>
             </div>
             <div class="field">
               <div class="ui left icon input">
                 <i class="lock icon"></i>
                   <input type="password" name="password" placeholder="请输入管理员密码"/>
               </div>
             </div>
             <div class="field">
               <div class="ui left icon input">
                 <i class="lock icon"></i>
                   <input type="text" name="code" id="code" maxlength="4" placeholder="请输入验证码"/>
                  <div>
                   <a href="javascript:void(0);" title="点击更换验证码">
                     <img id="imgVerify" src="" alt="更换验证码" style="width:100px;height:36px;border-radius: 5px;" onclick="getVerify();">
                   </a>
                  </div>
               </div>
             </div>
             <button class="ui fluid large teal submit button">登   录</button>
           </div>

           <div class="ui error mini message"></div>
           <div class="ui mini negative message" th:unless="${#strings.isEmpty(message)}" th:text="${message}">用户名和密码错误</div>
         </form>
       </div>
     </div>
   </div>
 </div>

<script src="../static/js/jquery-3.6.0.min.js" th:src="@{/js/jquery-3.6.0.min.js}"></script>
<script src="../static/js/semantic.min.js" th:src="@{/js/semantic.min.js}"></script>


<script>
  getVerify();
  function getVerify() {
    document.getElementById("imgVerify").src = "/admin/getVerify?" + Math.random();
  }
  $('.ui.form').form({
    fields : {
      username : {
        identifier: 'username',
        rules: [{
          type : 'empty',
          prompt: '请输入用户名'
        }]
      },
      password : {
        identifier: 'password',
        rules: [{
          type : 'empty',
          prompt: '请输入密码'
        }]
      },
      code : {
        identifier: 'code',
        rules: [{
          type : 'empty',
          prompt: '请输入验证码'
        }]
      }
    },
      inline : true,
  });
</script>
</body>
</html>